/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yudisium;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

/**
 *
 * @author Antonius
 */
public class PanelDaftarYudisium extends JPanel{
    private JLabel labelnim,labelnama,labelprodi,labelnmrHp, labelperYud,labelperYudtgl,labelperYudbln, 
            labelperYudthn,labelfilesurat, labelkelYud,background,logo,fakultas, universitas;
    private JTextField textnim,textnama,textprodi,textnmrHp,textperYudtgl,textperYudbln,textperYudthn,
            textfilesurat,textdaftrNil,textnaskaTA,textbebasLab,textbebasDos,textbuktiLapKP,textsuratKKL;
    private JCheckBox labeldaftrNil,labelnaskaTA,labelbebasLab,
            labelbebasDos,labelbuktiLapKP,labelsuratKKL;
    private JButton tombolbatal,tombolsimpan,tombolvalidasi,tombolCariFile;
    private File file;
    
    public PanelDaftarYudisium() {
        this.setSize(600,500);
        this.setLayout(null);
       
        textnim = new javax.swing.JFormattedTextField();
        labelnim = new JLabel();
        labelnim.setText("NIM ");
        this.add(labelnim);
        labelnim.setBounds(10, 150, 80, 25);
        textnim.setText(" ");
        this.add(textnim);
        textnim.setBounds(20, 175, 200, 20);
        
        textnama= new javax.swing.JFormattedTextField();
        labelnama = new JLabel();
        labelnama.setText("NAMA ");
        this.add(labelnama);
        labelnama.setBounds(10, 197, 80, 25);
        textnama.setText(" ");
        this.add(textnama);
        textnama.setBounds(20, 222, 200, 20);
        
        textprodi= new javax.swing.JFormattedTextField();
        labelprodi = new JLabel();
        labelprodi.setText("Prodi ");
        this.add(labelprodi);
        labelprodi.setBounds(10, 244, 160, 25);
        textprodi.setText(" ");
        this.add(textprodi);
        textprodi.setBounds(20, 269, 200, 20);
        
        textnmrHp= new javax.swing.JFormattedTextField();
        labelnmrHp = new JLabel();
        labelnmrHp.setText("Nomor HP ");
        this.add(labelnmrHp);
        labelnmrHp.setBounds(350, 150, 80, 25);
        textnmrHp.setText(" ");
        this.add(textnmrHp);
        textnmrHp.setBounds(360, 175, 200, 20);
        
        labelperYud = new JLabel();
        labelperYud.setText("Periode Yudisium :");
        this.add(labelperYud);
        labelperYud.setBounds(350, 197, 200, 20);
        
        textperYudtgl = new javax.swing.JFormattedTextField();
        labelperYudtgl = new JLabel();
        labelperYudtgl.setText("Tanggal :");
        this.add(labelperYudtgl);
        labelperYudtgl.setBounds(370, 222, 200, 20);
        textperYudtgl.setText(" ");
        this.add(textperYudtgl);
        textperYudtgl.setBounds(430, 222, 50, 20);
        
        textperYudbln = new javax.swing.JFormattedTextField();
        labelperYudbln = new JLabel();
        labelperYudbln.setText("Bulan     :");
        this.add(labelperYudbln);
        labelperYudbln.setBounds(370, 250, 50, 20);
        textperYudbln.setText(" ");
        this.add(textperYudbln);
        textperYudbln.setBounds(430, 250, 50, 20);
        
        textperYudthn = new javax.swing.JFormattedTextField();
        labelperYudthn = new JLabel();
        labelperYudthn.setText("Tahun    :");
        this.add(labelperYudthn);
        labelperYudthn.setBounds(370, 275, 50, 20);
        textperYudthn.setText(" ");
        this.add(textperYudthn);
        textperYudthn.setBounds(430, 275, 50, 20);
        
        labelkelYud = new JLabel();
        labelkelYud.setText("Kelengkapan Yudisium ");
        this.add(labelkelYud);
        labelkelYud.setBounds(10, 300, 300, 25);
        
        textdaftrNil = new javax.swing.JFormattedTextField();
        labeldaftrNil = new JCheckBox("Daftar Nilai ");
        labeldaftrNil.setLocation(20,320);
        labeldaftrNil.setSize(labeldaftrNil.getPreferredSize());
        this.add(labeldaftrNil);
        labeldaftrNil.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labeldaftrNil.isSelected())textdaftrNil.setText("lengkap");
                else textdaftrNil.setText("NULL");
            }
        });
        
        textnaskaTA = new javax.swing.JFormattedTextField();
        labelnaskaTA = new JCheckBox("Naskah TA ");
        labelnaskaTA.setLocation(20,340);
        labelnaskaTA.setSize(labelnaskaTA.getPreferredSize());
        this.add(labelnaskaTA);
        labelnaskaTA.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labelnaskaTA.isSelected())textnaskaTA.setText("Lengkap");
                else textnaskaTA.setText("NULL");
            }
        });
        
        textbebasLab = new javax.swing.JFormattedTextField();
        labelbebasLab = new JCheckBox("Bebas Pinjam dari Lab ");
        labelbebasLab.setLocation(20,360);
        labelbebasLab.setSize(labelbebasLab.getPreferredSize());
        this.add(labelbebasLab);
        labelbebasLab.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labelbebasLab.isSelected())textbebasLab.setText("Bebas");
                else textbebasLab.setText("NULL");
            }
        });
        
        textbebasDos = new javax.swing.JFormattedTextField();
        labelbebasDos = new JCheckBox("Bebas Pinjam dari Dosen ");
        labelbebasDos.setLocation(300, 320);
        labelbebasDos.setSize(labelbebasDos.getPreferredSize());
        this.add(labelbebasDos);
        labelbebasDos.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labelbebasDos.isSelected())textbebasDos.setText("Bebas");
                else textbebasDos.setText("NULL");
            }
        });
        
        textbuktiLapKP = new javax.swing.JFormattedTextField();
        labelbuktiLapKP = new JCheckBox("Bukti Penyerahan Lap.KP ");
        labelbuktiLapKP.setLocation(300, 340);
        labelbuktiLapKP.setSize(labelbuktiLapKP.getPreferredSize());
        this.add(labelbuktiLapKP);
        labelbuktiLapKP.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labelbuktiLapKP.isSelected())textbuktiLapKP.setText("Ada");
                else textbuktiLapKP.setText("NULL");
            }
        });
        
        textsuratKKL = new javax.swing.JFormattedTextField();
        labelsuratKKL = new JCheckBox("Surat Keterangan KKL/KL ");
        labelsuratKKL.setLocation(300, 360);
        labelsuratKKL.setSize(labelsuratKKL.getPreferredSize());
        this.add(labelsuratKKL);
        labelsuratKKL.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                
                if(labelsuratKKL.isSelected())textsuratKKL.setText("Ada");
                else textsuratKKL.setText("NULL");
            }
        });
        
        textfilesurat= new javax.swing.JFormattedTextField();
        labelfilesurat = new JLabel();
        labelfilesurat.setText("File surat keterangan bebas pinjam ");
        this.add(labelfilesurat);
        labelfilesurat.setBounds(10, 400, 300, 20);
        textfilesurat.setText(" ");
        this.add(textfilesurat);
        textfilesurat.setBounds(20, 420, 200, 20);
        
        tombolCariFile = new JButton("UPLOAD");
        this.add(tombolCariFile);
        tombolCariFile.setBounds(230, 420, 100, 20);
     
        tombolCariFile.addActionListener(new ActionListener() {

                @Override
            public void actionPerformed(ActionEvent e) {
                tombolCariFileAction();
            }
        });
        
        tombolbatal = new JButton();
        tombolbatal.setText("Keluar");
        this.add(tombolbatal);
        tombolbatal.setBounds(479, 440, 100, 20);
        
        tombolbatal.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
//                FrameUtamaMahasiswa main = new FrameUtamaMahasiswa();
//                main.setVisible(false);
////                setVisible(false);
//                repaint();
                quitAction();
            }

            private void quitAction() {
                System.exit(0);
            }
        });
        
        tombolsimpan = new JButton();
        tombolsimpan.setText("Simpan");
        this.add(tombolsimpan);
        tombolsimpan.setBounds(370, 440, 100, 20);

        tombolsimpan.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Yudisium yudisium = new  Yudisium();
                yudisium.setNim(textnim.getText());
                yudisium.setNama(textnama.getText());
                yudisium.setProdi(textprodi.getText());
                yudisium.setNomorHp(textnmrHp.getText());
                yudisium.setPerYudtgl(textperYudtgl.getText());
                yudisium.setPerYudbln(textperYudbln.getText());
                yudisium.setPerYudthn(textperYudthn.getText());
                yudisium.setDaftarNilai(textdaftrNil.getText());
                yudisium.setNaskahTA(textnaskaTA.getText());
                yudisium.setBebasLab(textbebasLab.getText());
                yudisium.setBebasDos(textbebasDos.getText());
                yudisium.setBuktiKP(textbuktiLapKP.getText());
                yudisium.setSuratKKL(textsuratKKL.getText());
//                yudisium.setFileSuratket(file);

                try {
                    //
                                    PengendaliPendaftaranYudisium.tambahTabelyudisium(yudisium);
                } catch (SQLException ex) {
                    Logger.getLogger(PanelDaftarYudisium.class.getName()).log(Level.SEVERE, null, ex);
                }
                
//                PengendaliPendaftaranYudisium n = new PengendaliPendaftaranYudisium();
//                try {
//                    n.tambahTabelyudisium(yudisium);
//                } catch (SQLException ex) {
//                    Logger.getLogger(PanelDaftarYudisium.class.getName()).log(Level.SEVERE, null, ex);
//                }
                JOptionPane.showMessageDialog(null, "Data Berhasil Disimpan");
            }
        });   
        
        logo = new JLabel(new ImageIcon("usd.gif"));
        this.add(logo);
        logo.setBounds(10, 10, 150,150);
        
        universitas = new JLabel("Universitas");
        universitas.setFont(new Font("Ravie", Font.PLAIN, 25));
        universitas.setForeground(Color.BLACK);
        universitas.setBounds(155, 60, 400, 40);
        this.add(universitas);
        universitas = new JLabel("Sanata Dharma");
        universitas.setFont(new Font("Ravie", Font.PLAIN, 25));
        universitas.setForeground(Color.BLACK);
        universitas.setBounds(155, 90, 400, 40);
        this.add(universitas);
        fakultas = new JLabel("Fakultas Sains Dan Teknologi");
        fakultas.setFont(new Font("Ravie", Font.PLAIN, 15));
        fakultas.setBounds(155, 120, 400, 40);
        fakultas.setForeground(Color.BLACK);
        this.add(fakultas);
        
        background = new JLabel(new ImageIcon("panel.jpg"));
        this.add(background);
        background.setBounds(0, 0, 800, 655);
    }
    
    public void tombolCariFileAction(){
        
    }
}
